<template>
	<view>
		<view class="mescrollBox margin30">
<!-- 			<view class="flex-start" >
				<view class="ordernavmain1">
					<view class="ordereach" :class="activenav1 == 1 ? 'activenav1':''" @click="navclick1(1)">大件产品</view>
					<view class="ordereach" :class="activenav1 == 0 ? 'activenav1':''" @click="navclick1(0)">小件产品</view>
					<view class="tag flex row-center" style="margin-left: 300rpx;" @tap="onPriceSort">
						<text class="primary">价格</text>
						<view class="arrow-icon flex-col col-center row-center">
							<u-icon name="arrow-up-fill" :class="price ==2 ? 'primary' : 'normal'"></u-icon>
							<u-icon name="arrow-down-fill" :class="price ==1 ? 'primary' : 'normal'"></u-icon>
						</view>
					</view>
				</view>
			</view> -->
			<u-search v-model="keyword" shape="round" background="white" placeholder="请输入搜索关键词" @search="changeTab('first')"
				@custom="changeTab" />
			<view class="row_box">
				<view class="row flex-start" v-for="(item,index) in data" :key="index" @click="apifun.navigate('/bundle/pages/goodsDetail/index?id='+item.id)">
					<image :src="item.image" mode=""></image>
					<view class="row_ri">
						<view class="name ellipsis02">{{item.name}}</view>
						<view class="row_price"><text class="Blue">￥</text>{{item.max_price}}</view>
						<!-- <view class="earnings"><text class="Blue">￥</text>{{item.distribution_price}}</view> -->
						<view class="" v-if="item.is_distribution_shop==1">
							<view v-for="(item1,index1) in item.distribution_shop.first_rank" class="earnings">直接推客：{{item1.name}}<text class="Blue">￥</text>{{item1.price}}</view>
							<view v-for="(item1,index1) in item.distribution_shop.second_rank" class="earnings">间接推客：{{item1.name}}<text class="Blue">￥</text>{{item1.price}}</view>
						</view>
						<view class="" v-if="item.is_distribution_price==1">
							<view class="earnings"><text class="Blue">直接推客：￥</text>{{item.distribution_price}}</view>
						</view>
						<view class="" v-if="item.is_distribution_order_price==1">
							<view class="earnings"><text class="Blue">间接推客：￥</text>{{item.distribution_order_price}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {usergoods} from '@/api/user';
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		data() {
			return {
				data:[],
				activenav1: 1,
				price: 2,
				keyword: "",
			}
		},
		onLoad() {
			this.getusergoods()
		},
		methods: {
			changeTab(val) {
				this.data = []
				this.getusergoods()
			},
			navclick1(type) { //切换状态
				let that = this;
				that.activenav1 = type;
				that.getusergoods()
			},
			onPriceSort() {
				this.price = this.price == 2 ? 1 : 2
				this.getusergoods()
			},
			async getusergoods(){
				const {
					data,
					code
				} = await usergoods({
					goods_type:this.activenav1,
					order_by:this.price,
					keyword:this.keyword,
				})
				if (code == 1) {
					this.data = data;
					// if(data.level==3){
					// 	this.type=0
					// }else{
					// 	this.type=2
					// }
					// this.getRankList()
				}
			},
		}
	}
</script>

<style>
	.ordernavmain1 {
		width: 690rpx;
		background-color: #ffffff;
		border-radius: 12rpx;
		padding: 26rpx 16rpx;
		display: flex;
		justify-content: start;
		margin-bottom: 30rpx;
		box-sizing: border-box;
	}
	.ordereach {
			position: relative;
			color: #0A0A0A;
			font-size: 28rpx;
			width: 130rpx;
			padding: 4rpx 0;
			text-align: center;
			border-radius: 40rpx;
		}
	.activenav1::after {
		font-size: 32rpx;
		position: absolute;
		left: 50%;
		top: 50rpx;
		content: "";
		display: block;
		width: 60rpx;
		margin-left: -30rpx;
		height: 4rpx;
		background-color: #f5335e;
		border-radius: 2rpx;
	}
	.activenav1 {
		font-size: 28rpx;
		color: #f5335e;
	}
	.tag {
		height: 100%;
	}
	.arrow-icon {
		transform: scale(0.46);
	}
	.normal{
		color: #545454;
	}
	.ellipsis02{
		width: 100%;
		overflow: hidden;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}
	.row{
		padding: 12rpx 0 12rpx 20rpx;
		background-color: #fff;
		margin-top: 12rpx;
		border-radius: 10rpx;
	}
	.row image{
		width: 180rpx;
		height: 180rpx;
		border-radius: 14rpx;
		margin-right: 18rpx;
		/* border: aqua solid 1rpx; */
	}
	.name{
		width: 456rpx;
	}
	.row_price{
		margin: 12rpx 0;
	}
	.earnings{
		color: #f5335e;
	}
	.Blue{
		font-size: 22rpx;
	}
	.row_box{
		/* background-color: #fff; */
		/* margin-top: -32rpx; */
		margin-top: 22rpx;
	}
</style>
